import React,{Component} from "react"
import  "./InputTest.scss"
export default class InputTest extends Component{

   showData1=()=>{
       let {input1}=this;
       alert(input1.value);
   }
   showData2=()=>{
       let {input2}=this;
       alert(input2.value);
   }
   myRef=React.createRef();//最新写法
   showData3=()=>{
       let { value }=this.myRef.current;
       console.log(value);
   }
    render() {
    return(
        <div>
            <input ref={c => this.input1=c} type={"text"} placeholder={"点击按钮输出"}  />
            <button onClick={this.showData1}>点击</button>
            <input onBlur={this.showData2} ref={c => this.input2=c} type={"text"} placeholder={"失去焦点输出"}  />
            <input onBlur={this.showData3} ref={this.myRef} placeholder={"最新的ref"} />


        </div>
    )
    }
}
